package admin;

import Dao.communityDao;
import Dao.communityDaoImpl;
import been.Announcements;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
@WebServlet(value = "/findAllAnnouncement1")
public class findAllAnnouncementServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        communityDao dao = new communityDaoImpl();
        ArrayList<Announcements> announcementsList = new ArrayList<>();
        try {
            announcementsList= (ArrayList<Announcements>) dao.findAllAnnouncements();
            request.setAttribute("announcementsList", announcementsList);
            request.getRequestDispatcher("/WEB-INF/admin/findAllAnnouncement1.jsp").forward(request,response);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
